home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 December / CHIPNET Aralık 1997.iso / linux / redhat / misc / src / install / config.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-11  |  1.1 KB  |  68 lines

  1. #include <newt.h>
  2. #include <sys/wait.h>
  3. #include <unistd.h>
  4.  
  5. #include "config.h"
  6. #include "install.h"
  7. #include "log.h"
  8.  
  9. static int runConfigTool(char * tool) {
  10.     int childpid;
  11.     int status;
  12.  
  13.     logMessage("running %s", tool);
  14.     newtSuspend();
  15.  
  16.     if (!(childpid = fork())) {
  17.     chroot("/mnt");
  18.     chdir("/");
  19.     execl(tool, tool, NULL);
  20.     exit(2);
  21.     } 
  22.  
  23.     waitpid(childpid, &status, 0);
  24.     newtResume();
  25.     if (WIFEXITED(status))
  26.     return 0;
  27.     
  28.     if (WEXITSTATUS(status) == 1) {
  29.     logMessage("    tool canceled");
  30.     return INST_CANCEL;
  31.     }
  32.  
  33.     logMessage("    tool failed");
  34.  
  35.     return INST_ERROR;
  36. }
  37.  
  38. int timeConfig(void) {
  39.     return runConfigTool("/usr/sbin/timeconfig");
  40. }
  41.  
  42. int kbdConfig(void) {
  43.     return runConfigTool("/usr/sbin/kbdconfig");
  44. }
  45.  
  46. int mouseConfig(void) {
  47.     return runConfigTool("/usr/sbin/mouseconfig");
  48. }
  49.  
  50. void configPCMCIA(char * pcic) {
  51.     FILE * f;
  52.  
  53.     if (testing) return;
  54.  
  55.     f = fopen("/mnt/etc/sysconfig/pcmcia", "w");
  56.     if (pcic) {
  57.     fprintf(f, "PCMCIA=yes\n");
  58.     fprintf(f, "PCIC=%s\n", pcic);
  59.     } else {
  60.     fprintf(f, "PCMCIA=no\n");
  61.     fprintf(f, "PCIC=\n");
  62.     }
  63.  
  64.     fprintf(f, "PCIC_OPTS=\nCORE_OPTS=\n");
  65.  
  66.     fclose(f);
  67. }
  68.